home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / PInterfaces / CursorDevices.p < prev    next >
Encoding:
Text File  |  1996-05-29  |  7.8 KB  |  235 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        CursorDevices.p
  3.  
  4.      Contains:    Cursor Devices (mouse/trackball/etc) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1.3
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT CursorDevices;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __CURSORDEVICES__}
  30. {$SETC __CURSORDEVICES__ := 1}
  31.  
  32. {$I+}
  33. {$SETC CursorDevicesIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __TYPES__}
  38. {$I Types.p}
  39. {$ENDC}
  40. {    ConditionalMacros.p                                            }
  41.  
  42. {$IFC UNDEFINED __MIXEDMODE__}
  43. {$I MixedMode.p}
  44. {$ENDC}
  45.  
  46. {$PUSH}
  47. {$ALIGN MAC68K}
  48. {$LibExport+}
  49. {
  50.                        * * *  W A R N I N G  * * * 
  51.  
  52.     On currently shipping PowerMacs, the CursorDevices manager is implemented
  53.     in 68K code and emulated.  Unfortunately, the MixedMode glue in InterfaceLib
  54.     is incorrect.  It and the 1.0 version of this file had incorrect parameter
  55.     lists for most functions.
  56.     
  57.     As a first step to avoid runtime errors, the functions in this file were 
  58.     renamed (e.g. from"CrsrDevButtons" to "CursorDeviceButtons").  This will result
  59.     in a link time error if a PowerPC application tries to call the functions.
  60.     When InterfaceLib is fixed, the new names will be exported and PowerPC
  61.     code will then be able to call them.
  62.     
  63. }
  64.     
  65. TYPE
  66.     ButtonOpcode = INTEGER;
  67.  
  68. { ButtonOpcodes }
  69.  
  70. CONST
  71.     kButtonNoOp                    = 0;                            { No action for this button }
  72.     kButtonSingleClick            = 1;                            { Normal mouse button }
  73.     kButtonDoubleClick            = 2;                            { Click-release-click when pressed }
  74.     kButtonClickLock            = 3;                            { Click on press, release on next press }
  75.     kButtonCustom                = 6;                            { Custom behavior, data = CursorDeviceCustomButtonUPP }
  76.  
  77. { Device Classes }
  78.     kDeviceClassAbsolute        = 0;                            { a flat-response device }
  79.     kDeviceClassMouse            = 1;                            { mechanical or optical mouse }
  80.     kDeviceClassTrackball        = 2;                            {  trackball  }
  81.     kDeviceClassTrackPad        = 3;
  82.     kDeviceClass3D                = 6;                            { a 3D pointing device }
  83.  
  84. { Structures used in Cursor Device Manager calls }
  85.  
  86. TYPE
  87.     CursorData = RECORD
  88.         nextCursorData:            ^CursorData;                            { next in global list }
  89.         displayInfo:            Ptr;                                    { unused (reserved for future) }
  90.         whereX:                    Fixed;                                    { horizontal position }
  91.         whereY:                    Fixed;                                    { vertical position }
  92.         where:                    Point;                                    { the pixel position }
  93.         isAbs:                    BOOLEAN;                                { has been stuffed with absolute coords }
  94.         buttonCount:            SInt8; (* UInt8 *)                        { number of buttons currently pressed }
  95.         screenRes:                INTEGER;                                { pixels per inch on the current display }
  96.         privateFields:            ARRAY [0..21] OF INTEGER;                { fields use internally by CDM }
  97.     END;
  98.  
  99.     CursorDataPtr = ^CursorData;
  100.  
  101.     CursorDevice = RECORD
  102.         nextCursorDevice:        ^CursorDevice;                            { pointer to next record in linked list }
  103.         whichCursor:            ^CursorData;                            { pointer to data for target cursor }
  104.         refCon:                    LONGINT;                                { application-defined }
  105.         unused:                    LONGINT;                                { reserved for future }
  106.         devID:                    OSType;                                    { device identifier (from ADB reg 1) }
  107.         resolution:                Fixed;                                    { units/inch (orig. from ADB reg 1) }
  108.         devClass:                SInt8; (* UInt8 *)                        { device class (from ADB reg 1) }
  109.         cntButtons:                SInt8; (* UInt8 *)                        { number of buttons (from ADB reg 1) }
  110.         filler1:                SInt8; (* UInt8 *)                        { reserved for future }
  111.         buttons:                SInt8; (* UInt8 *)                        { state of all buttons }
  112.         buttonOp:                ARRAY [0..7] OF SInt8; (* UInt8 *)        { action performed per button }
  113.         buttonTicks:            ARRAY [0..7] OF LONGINT;                { ticks when button last went up (for debounce) }
  114.         buttonData:                ARRAY [0..7] OF LONGINT;                { data for the button operation }
  115.         doubleClickTime:        LONGINT;                                { device-specific double click speed }
  116.         acceleration:            Fixed;                                    { current acceleration }
  117.         privateFields:            ARRAY [0..14] OF INTEGER;                { fields used internally to CDM }
  118.     END;
  119.  
  120.     CursorDevicePtr = ^CursorDevice;
  121.  
  122. { for use with CursorDeviceButtonOp when opcode = kButtonCustom }
  123.     {
  124.         CursorDeviceCustomButtonProcPtr uses register based parameters on the 68k and cannot
  125.         be written in or called from a high-level language without the help of
  126.         mixed mode or assembly glue.
  127.  
  128.         In:
  129.          => ourDevice       A2.L
  130.          => button          D3.W
  131.     }
  132.     CursorDeviceCustomButtonProcPtr = Register68kProcPtr;  { register PROCEDURE CursorDeviceCustomButton(ourDevice: CursorDevicePtr; button: INTEGER); }
  133.     CursorDeviceCustomButtonUPP = UniversalProcPtr;
  134.  
  135. CONST
  136.     uppCursorDeviceCustomButtonProcInfo = $000ED802; { Register PROCEDURE (4 bytes in A2, 2 bytes in D3); }
  137.  
  138. FUNCTION NewCursorDeviceCustomButtonProc(userRoutine: CursorDeviceCustomButtonProcPtr): CursorDeviceCustomButtonUPP;
  139.     {$IFC NOT GENERATINGCFM }
  140.     INLINE $2E9F;
  141.     {$ENDC}
  142.  
  143. PROCEDURE CallCursorDeviceCustomButtonProc(ourDevice: CursorDevicePtr; button: INTEGER; userRoutine: CursorDeviceCustomButtonUPP);
  144.     {$IFC NOT GENERATINGCFM}
  145.     {To be implemented:  Glue to move parameters into registers.}
  146.     {$ENDC}
  147.  
  148. FUNCTION CursorDeviceMove(ourDevice: CursorDevicePtr; deltaX: LONGINT; deltaY: LONGINT): OSErr;
  149.     {$IFC NOT GENERATINGCFM}
  150.     INLINE $7000, $AADB;
  151.     {$ENDC}
  152. FUNCTION CursorDeviceMoveTo(ourDevice: CursorDevicePtr; absX: LONGINT; absY: LONGINT): OSErr;
  153.     {$IFC NOT GENERATINGCFM}
  154.     INLINE $7001, $AADB;
  155.     {$ENDC}
  156. FUNCTION CursorDeviceFlush(ourDevice: CursorDevicePtr): OSErr;
  157.     {$IFC NOT GENERATINGCFM}
  158.     INLINE $7002, $AADB;
  159.     {$ENDC}
  160. FUNCTION CursorDeviceButtons(ourDevice: CursorDevicePtr; buttons: INTEGER): OSErr;
  161.     {$IFC NOT GENERATINGCFM}
  162.     INLINE $7003, $AADB;
  163.     {$ENDC}
  164. FUNCTION CursorDeviceButtonDown(ourDevice: CursorDevicePtr): OSErr;
  165.     {$IFC NOT GENERATINGCFM}
  166.     INLINE $7004, $AADB;
  167.     {$ENDC}
  168. FUNCTION CursorDeviceButtonUp(ourDevice: CursorDevicePtr): OSErr;
  169.     {$IFC NOT GENERATINGCFM}
  170.     INLINE $7005, $AADB;
  171.     {$ENDC}
  172. FUNCTION CursorDeviceButtonOp(ourDevice: CursorDevicePtr; buttonNumber: INTEGER; opcode: ButtonOpcode; data: LONGINT): OSErr;
  173.     {$IFC NOT GENERATINGCFM}
  174.     INLINE $7006, $AADB;
  175.     {$ENDC}
  176. FUNCTION CursorDeviceSetButtons(ourDevice: CursorDevicePtr; numberOfButtons: INTEGER): OSErr;
  177.     {$IFC NOT GENERATINGCFM}
  178.     INLINE $7007, $AADB;
  179.     {$ENDC}
  180. FUNCTION CursorDeviceSetAcceleration(ourDevice: CursorDevicePtr; acceleration: Fixed): OSErr;
  181.     {$IFC NOT GENERATINGCFM}
  182.     INLINE $7008, $AADB;
  183.     {$ENDC}
  184. FUNCTION CursorDeviceDoubleTime(ourDevice: CursorDevicePtr; durationTicks: LONGINT): OSErr;
  185.     {$IFC NOT GENERATINGCFM}
  186.     INLINE $7009, $AADB;
  187.     {$ENDC}
  188. FUNCTION CursorDeviceUnitsPerInch(ourDevice: CursorDevicePtr; resolution: Fixed): OSErr;
  189.     {$IFC NOT GENERATINGCFM}
  190.     INLINE $700A, $AADB;
  191.     {$ENDC}
  192. FUNCTION CursorDeviceNextDevice(VAR ourDevice: CursorDevicePtr): OSErr;
  193.     {$IFC NOT GENERATINGCFM}
  194.     INLINE $700B, $AADB;
  195.     {$ENDC}
  196. FUNCTION CursorDeviceNewDevice(VAR ourDevice: CursorDevicePtr): OSErr;
  197.     {$IFC NOT GENERATINGCFM}
  198.     INLINE $700C, $AADB;
  199.     {$ENDC}
  200. FUNCTION CursorDeviceDisposeDevice(ourDevice: CursorDevicePtr): OSErr;
  201.     {$IFC NOT GENERATINGCFM}
  202.     INLINE $700D, $AADB;
  203.     {$ENDC}
  204.  
  205. {
  206.                        * * *  W A R N I N G  * * * 
  207.                 
  208.     Even though the glue in InterfaceLib on PowerMacs for CursorDevices
  209.     is generally wrong, the two popular routines CrsrDevNextDevice
  210.     and CrsrDevMoveTo actually work.  Because we still don't have a 
  211.     fixed library, we are adding back prototypes (with the old name)
  212.     so that these functions can be called.
  213.  
  214.  
  215. }
  216. FUNCTION CrsrDevMoveTo(ourDevice: CursorDevicePtr; absX: LONGINT; absY: LONGINT): OSErr;
  217.     {$IFC NOT GENERATINGCFM}
  218.     INLINE $7001, $AADB;
  219.     {$ENDC}
  220. FUNCTION CrsrDevNextDevice(VAR ourDevice: CursorDevicePtr): OSErr;
  221.     {$IFC NOT GENERATINGCFM}
  222.     INLINE $700B, $AADB;
  223.     {$ENDC}
  224.  
  225. {$ALIGN RESET}
  226. {$POP}
  227.  
  228. {$SETC UsingIncludes := CursorDevicesIncludes}
  229.  
  230. {$ENDC} {__CURSORDEVICES__}
  231.  
  232. {$IFC NOT UsingIncludes}
  233.  END.
  234. {$ENDC}
  235.